let { noop } = require('./util');

const navigator = {
  platform: __getOS(),
  language: __getCurrentLanguage(),
  appVersion: '5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 NetType/WIFI Language/zh_CN',
  onLine: true, //FIXME:

  geolocation: {
    getCurrentPosition: noop,
    watchPosition: noop,
    clearWatch: noop
  },

  maxTouchPoints: 10 //FIXME: getting the number from OS.
}

var osVersion = __getOSVersion();

var appVersionPrefix = '5.0 (';
var appVersionSuffix_1 = ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 ';
var appVersionSuffix_2 = 'Safari/537.36';

var appVersionContent = '';
var platform = navigator.platform;
var mobile = '';

if (platform === 'Android') {
    appVersionContent = 'Linux; Android Cocos';
    mobile = 'Mobile ';
}
else if (platform === 'iOS') {
    appVersionContent = 'iPhone; CPU iPhone OS ';
    mobile = 'Mobile ';
    osVersion = osVersion.replace('\.', '_');
    appVersionSuffix_1 = ' like Mac OS Cocos' + appVersionSuffix_1;
}
else if (platform === 'OS X') {
    appVersionContent = 'Macintosh; Intel Mac OS Cocos ';
    osVersion = osVersion.replace('\.', '_');
}
else if (platform === 'Windows') {
    appVersionContent = 'Windows NT ; Win64; x64  ';
}

navigator.appVersion = appVersionPrefix + appVersionContent + osVersion + appVersionSuffix_1 + mobile + appVersionSuffix_2;
navigator.userAgent = 'Mozilla/' + navigator.appVersion;

module.exports = navigator;
